<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

Route::get('/', function () {
    return redirect(url('/index'));
});
Route::get('img/{id}/{w?}/{h?}', 'FileController@image');
Route::group(['namespace' => 'Admin', 'prefix' => 'admin'], function () {
    Route::get('/', function () {
        return redirect(url('admin/index'));
    });
    Route::group(['prefix' => 'public'], function () {
        Route::get('index', 'PublicController@getIndex')->middleware('loginAuth');
        Route::get('login', 'PublicController@login')->name('adminLogin');
        Route::post('loging', 'PublicController@loging');
        Route::get('icon', 'PublicController@icon');
    });
    Route::group(['middleware' => 'loginAuth'], function () {

        Route::group(['prefix' => 'index'], function () {
            Route::get('', 'IndexController@index')->name('adminHome');
            Route::get('profile', 'IndexController@profile')->name('adminProfile');
            Route::post('changePassword', 'IndexController@changePassword');
            Route::get('changePassword', 'IndexController@changePasswordView')->name('changePassword');
            Route::post('initPassword', 'IndexController@initPassword');
            Route::post('skin', 'IndexController@skin');
        });

        /**
         * 系统代码值
         */
        Route::group(['prefix' => 'article'], function () {
            Route::get('', 'ArticleController@index')->middleware('adminPermission');
            Route::get('create', 'ArticleController@create')->middleware('adminPermission');
            Route::get('edit/{id}', 'ArticleController@edit')->middleware('adminPermission');
            Route::post('save', 'ArticleController@save');
            Route::post('destroy/{id}', 'ArticleController@destroy')->middleware('adminPermission');
        });

        /**
         * 系统代码
         */
        Route::group(['prefix' => 'code'], function () {
            Route::get('', 'CodeController@index')->middleware('adminPermission');
            Route::get('create', 'CodeController@create')->middleware('adminPermission');
            Route::get('edit/{id}', 'CodeController@edit')->middleware('adminPermission');
            Route::post('save', 'CodeController@save');
            Route::post('destroy/{id}', 'CodeController@destroy')->middleware('adminPermission');
            /**
             * 系统代码值
             */
            Route::group(['prefix' => 'value'], function () {

                Route::get('create/{code}', 'CodeValueController@create')->middleware('adminPermission');
                Route::get('edit/{id}', 'CodeValueController@edit')->middleware('adminPermission');
                Route::post('save', 'CodeValueController@save');
                Route::post('destroy/{id}', 'CodeValueController@destroy')->middleware('adminPermission');
                Route::get('{code}', 'CodeValueController@index')->middleware('adminPermission');
            });
        });

        /**
         * 系统权限
         */
        Route::group(['prefix' => 'permission'], function () {

            Route::get('create/{module_id}', 'PermissionController@create')->middleware('adminPermission');
            Route::get('edit/{id}', 'PermissionController@edit')->middleware('adminPermission');
            Route::post('destroy/{id}', 'PermissionController@destroy')->middleware('adminPermission');
            Route::post('save', 'PermissionController@save');
            Route::get('{module_id}', 'PermissionController@index')->middleware('adminPermission');
        });

        /**
         * 系统用户
         */
        Route::group(['prefix' => 'user'], function () {
            Route::get('', 'UserController@index')->middleware('adminPermission');
            Route::get('create', 'UserController@create')->middleware('adminPermission');
            Route::get('edit/{id}', 'UserController@edit')->middleware('adminPermission');
            Route::post('save', 'UserController@save');
            Route::post('destroy/{id}', 'UserController@destroy')->middleware('adminPermission');
            Route::get('setPassword/{id}', 'UserController@setPasswordView')->middleware('adminPermission');
            Route::post('setPassword', 'UserController@setPassword');
            Route::post('status/{id}/{status}', 'UserController@status')->middleware('adminPermission');
        });
        /**
         * 系统用户
         */
        Route::group(['prefix' => 'role'], function () {
            Route::get('', 'RoleController@index')->middleware('adminPermission');
            Route::get('create', 'RoleController@create')->middleware('adminPermission');
            Route::get('edit/{id}', 'RoleController@edit')->middleware('adminPermission');
            Route::post('save', 'RoleController@save');
            Route::post('audit', 'RoleController@audit');
            Route::post('destroy/{id}', 'RoleController@destroy')->middleware('adminPermission');
            Route::get('audit/{tag}', 'RoleController@audit_view')->middleware('adminPermission');
        });


        /**
         * 系统权限模块
         */
        Route::group(['prefix' => 'module'], function () {
            Route::get('', 'ModuleController@index')->middleware('adminPermission');
            Route::get('create', 'ModuleController@create')->middleware('adminPermission');
            Route::get('actions', 'ModuleController@actions');
            Route::get('edit/{id}', 'ModuleController@edit')->middleware('adminPermission');
            Route::post('destroy/{id}', 'ModuleController@destroy')->middleware('adminPermission');
            Route::post('save', 'ModuleController@save');
        });
        /**
         * 导入日志
         */
        Route::group(['prefix' => 'import'], function () {
            Route::get('down/{type}/{id}', 'ImportLogController@down');
            Route::post('setSelectIds', 'ImportLogController@setSelectIds');
            Route::get('{type}', 'ImportLogController@index');
        });


        Route::group(['prefix' => 'setting'], function () {
            Route::get('', 'SettingController@index')->middleware('adminPermission');
            Route::post('save', 'SettingController@save');
        });
    });

    Route::group(['prefix' => 'file'], function () {
        Route::post('uploadImage', 'FileController@uploadImage');
        Route::post('editerImage', 'FileController@editerImage');
    });

});
